All Questions
Tagged with rubyunit-testing
41 questions
1vote
1answer
266views
RSpec: Compound Expectations
It's an exercise from a RSpec-course, which I'm currently doing. Task: Create a compound expectation, which asserts the string sportscar starts with the substring "sports" and ends with the ...
2votes
1answer
74views
Table class to fill array structure with values
The code creates a table and adds rows and columns. Does it make sense to write the code like this? Would you design it differently? Is there a better OOP approach to this? ...
2votes
0answers
84views
TDD for Ruby On Rails API for group event items
I found myself working in this coding exercise for a work offer. I tried to apply TDD in the process but I didn't get any feedback from the company and I really would like to know what can be improved ...
5votes
1answer
1kviews
ROT13 cipher challenge (HackerRank)
I just started learning Ruby and thought that this relatively simple HackerRank challenge would be a good opportunity to try to write clean, tested and documented code without getting bogged down in ...
3votes
2answers
613views
String calculator kata in Ruby
I've completed the string calculator kata in Ruby (spec from here - http://osherove.com/tdd-kata-1/). All tests currently pass. Could it be refactored further to improve readability? And could I make ...
2votes
0answers
997views
Rails CRUD feature specs (RSpec and Capybara)
The following feature spec tests CRUD operations for the users resource in a Rails 4.2.8 application. It includes tests for filtering, sorting and pagination ...
3votes
1answer
313views
4votes
1answer
2kviews
Rails & RSpec - Testing API with request specs and shared examples
I have written the following shared examples which are used in multiple request specs to test a namespaced RESTful JSON API. Application details: Rails 4.2, RSpec 3.5, Devise for authentication and ...
3votes
1answer
631views
Controller tests (Rails 4.2 and RSpec 3.5)
The following code is a controller spec used in a Rails 4.2 application with RSpec 3.5. I would greatly appreciate your suggestions on how to improve it (e.g., efficiency, readability, maintainability,...
2votes
2answers
127views
Fraction class with documentation
I have never worked with Ruby before, and thought I'd start working on learning it. For my first little implementation, I have created a simple fraction class. It would be nice if someone would check ...
2votes
2answers
426views
Title capitalization exercise from The Odin Project
I just finished the book title class exercise for The Odin Project and I would appreciate some honest feedback for my code. The code is intended to be "test-driven learning", and therefore emulates ...
2votes
1answer
268views
Analyze Shakespeare's Macbeth parsing XML from web using Nokogiri
This is a simple Ruby program to analyze the number of lines characters speak in Shakespeare's Macbeth using Nokogiri and open-uri to parse a given url containing xml. I wrote this as practice getting ...
2votes
2answers
144views
Random distribution in Ruby
Below is a Ruby implementation of a random statistical event, based on a hash with the actual observed counts of outcomes. I'd be interested in feedback in particular on what techniques I might use ...
8votes
2answers
241views
Error-testing be with cucumber/capybaraweb
I'm working on writing tests for a rails application using cucumber and capybara. I have a scenario for a user editing a post, and making it invalid. The scenario looks like this: ...
1vote
1answer
59views
Mini Test testing save on one and many trips
I know there is a balance to be struck between writing dry code and damp code but I have the feeling that this is a bit too repeative. Is there a terse yet self explainatory way to rewrite these tests?...